<script>
  function del_row_class(tr){
    $("."+tr).remove();
  }
  function add_row_tambahan(table,url,act,param){
    var no = parseInt($('#'+param).val());
    $('#'+param).val(no+1);
    $.post(url,{no:$('#'+param).val(),action:act},function(data){
        $(data).clone(true).insertBefore("#"+table+" #"+act);
    });
  }
</script>
<div id="main-content">
  <div class="container-fluid">
    <div class="row-fluid">
			<div class="span12">
				<div class="widget-block">
					<div class="widget-head">
						<h5><?php print $title?></h5>
            <div class="widget-control pull-right">
              <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="<?php print   site_url("crm/add-products/") ?>"><i class="icon-plus"></i><?php print lang("create_products")?></a></li>
              </ul>
            </div>
					</div>
					<div class="widget-content">
            <div class="widget-searchbox">
              <ul>
                <li class="row-counts">Total Post: <span id='total_row_products'><?php print $total?></span></li>
              </ul>
            </div>
            <div class="widget-box">
              <?php print $this->form_eksternal->form_open()?>
              <table class="table search">
                <tr>
                  <td><?php print lang("company")?></td>
                  <td><?php print $this->form_eksternal->form_input("s_title", $this->session->userdata("crm_market_target_search_title"))?></td>
                  <td>&nbsp;</td>
                  <td><?php print lang("user")?></td>
                  <td><?php print $this->form_eksternal->form_input("s_up_to", $this->session->userdata("crm_market_target_search_up_to"))?></td>
                </tr>
                <tr>
                  <td><?php print lang("email")?></td>
                  <td><?php print $this->form_eksternal->form_input("s_email", $this->session->userdata("crm_market_target_search_email"))?></td>
                  <td>&nbsp;</td>
                  <td><?php print lang("telphone")?></td>
                  <td><?php print $this->form_eksternal->form_input("s_telphone", $this->session->userdata("crm_market_target_search_telphone"))?></td>
                </tr>
                <tr>
                  <td colspan="5">
                    <button class="btn btn-primary" type="submit" name="cari" value="s"><?php print lang("search")?></button>
                    <button class="btn" type="submit" name="clear" value="c"><?php print lang("clear")?></button>
                  </td>
                </tr>
              </table>
                </form>
              <hr />
              <table id="inti-products" class="table table-striped">
                <thead>
                  <tr>
                    <th><?php print lang("thumb")?></th>
                    <th><?php print lang("product_name")?></th>
                    <th><?php print lang("product_code")?></th>
                    <th><?php print lang("product_category")?></th>
                    <th><?php print lang("product_brand")?></th>
                    <th><?php print lang("action")?></th>
                  </tr>
                </thead>
                <tbody id="ajax-body-products">
                </tbody>
              </table>
            </div>
          </div>
				</div>
			</div>
		</div>
  </div>
</div>

<script>
  $(document).ready( function () {
    
    del_row_class('ajax-products');
    add_row_tambahan('inti-products','<?php print site_url("crm/ajax-products")?>/'+$('#total_row_products').text(),'ajax-body-products');
    
  });
  function load_products(id){
    if(id == undefined){
      id = 0;
    }
    del_row_class('ajax-products');
    add_row_tambahan('inti-products','<?php print   site_url("crm/ajax-products")?>/'+$('#total_row_products').text()+'/'+id,'ajax-body-products');
    return false;
  }
  
</script>